import request from '@/utils/request'
import type { tradeMarkRes,tradeMark } from './type'

enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark',
  ADD_TRADE_URL = '/admin/product/baseTrademark/save',
  UPDATE_TRADE_URL = '/admin/product/baseTrademark/update',
  DELETE_TRADE_URL = '/admin/product/baseTrademark/remove'
}

export const reqGetTradeList = (pager: number, limit: number) =>
  request.get<any, tradeMarkRes>(API.TRADEMARK_URL + `/${pager}/${limit}`)

export const reqAddOrUpdateTrade = (data:tradeMark) => {
  if(data.id) {
    return request.put<any,any>(API.UPDATE_TRADE_URL,data)
  }else {
    return request.post<any,any>(API.ADD_TRADE_URL,data)
  }
}

export const reqDeleteTrade = (id:number) => {
  return request.delete(API.DELETE_TRADE_URL+`/${id}`)
}